package com.tfriend.framework.xml;

import java.util.Iterator;
import java.util.Map;

public class Root {
	private Map datasets = new CaseInsensitiveHashMap();
	
	public void addDataset(Dataset dataset) {
		this.datasets.put(dataset.getName().toUpperCase(), dataset);
	}
	
	public Dataset getDataset(String name) {
		return (Dataset)datasets.get(name.toUpperCase());
	}
	
	public int getDatasetCount() {
		return datasets.size();
	}
	
	public String[] getDatasetNames() {
		return getMapKeys(datasets);
	}
	
	public Map getDatasets() {
		return datasets;
	}
	
    static String[] getMapKeys(Map map) {
        if (map == null) {
            return null;
        }
        String[] ret = new String[map.size()];
        int inc = 0;
        for (Iterator i = map.keySet().iterator(); i.hasNext();) {
            ret[inc++] = (String) i.next();
        }

        return ret;
    }
}
